package zozopo.background.operator;

import java.sql.Connection;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.background.operator.operations.LimitedOS;
import zozopo.background.operator.operations.LimitedTB;
import zozopo.background.operator.operations.OperatorTB;
import zozopo.background.operator.operations.OperatorlimitedOS;
import zozopo.background.operator.operations.OperatorlimitedTB;
import zozopo.database.BusiDatabaseManager;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class InfoOperatorlimitedAction extends ActionSupport implements Action,SessionAware{
	//传入参数

	//分页参数
	
	//传出参数
	private List<LimitedTB> limitedList;
	
	private Map<String,OperatorTB> operatorInfoMap;
	
	private Map<Object, Object> session;
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	public String execute(){
		
		//权限处理
		//UserTB user = (UserTB) session.get("userInfo");
		
		OperatorTB operator = (OperatorTB)session.get("operatorInfo"); 

		if(operator == null){
			addFieldError("errormessage",getText("operator.timeoutornotlogin"));
			return NONE; 
		} 
		
		
		
		BusiDatabaseManager databaseConnection = new BusiDatabaseManager();
		Connection conn = databaseConnection.getConnection();

		

		OperatorlimitedOS operatorlimitedOS = new OperatorlimitedOS(conn);
		LimitedOS limitedOS = new LimitedOS(conn);

		Map<String,OperatorlimitedTB> operatorLimitedMap = null;
		if(operator != null){
			operatorLimitedMap = operatorlimitedOS.getUserlimitedMap(operator);
			limitedList = limitedOS.getLimitedList(operatorLimitedMap);
		}
		
		databaseConnection.releaseConnection(conn);
		
		return SUCCESS;

	}
	
	public void validate() {
		
		
		
	}
	
	
	
	
	
	public Map<String, OperatorTB> getOperatorInfoMap() {
		return operatorInfoMap;
	}
	public void setOperatorInfoMap(Map<String, OperatorTB> operatorInfoMap) {
		this.operatorInfoMap = operatorInfoMap;
	}
	public List<LimitedTB> getLimitedList() {
		return limitedList;
	}
	public void setLimitedList(List<LimitedTB> limitedList) {
		this.limitedList = limitedList;
	}

}
